import whisper  
import torch

device = "cuda:0" if torch.cuda.is_available() else "cpu"
model = whisper.load_model("base", download_root="./whisper_model/")

def call_whisper(audio_path:str):
    audio = whisper.load_audio(audio_path)
    audio = whisper.pad_or_trim(audio)
    mel = whisper.log_mel_spectrogram(audio).to(model.device)

    options = whisper.DecodingOptions(fp16=False, beam_size=5)

    result = whisper.decode(model, mel, options)  
    return result.text
